<template>
  <div class="loading-container" v-if="visible">
    <div class="loading-overlay">
      <div class="loading-spinner">
        <div class="spinner-ring"></div>
        <div class="spinner-ring"></div>
        <div class="spinner-ring"></div>
      </div>
      <p class="loading-text">{{ text }}</p>
    </div>
  </div>
</template>

<script setup>
const props = defineProps({
  visible: {
    type: Boolean,
    default: false
  },
  text: {
    type: String,
    default: '加载中...'
  }
})
</script>

<style lang="scss" scoped>
.loading-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.loading-overlay {
  text-align: center;
}

.loading-spinner {
  display: inline-block;
  position: relative;
  width: 80px;
  height: 80px;
  margin-bottom: 20px;
  
  .spinner-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 64px;
    height: 64px;
    margin: -32px 0 0 -32px;
    border-radius: 50%;
    border: 4px solid transparent;
    border-top-color: #00d4ff;
    animation: spin 1s linear infinite;
    
    &:nth-child(2) {
      width: 48px;
      height: 48px;
      margin: -24px 0 0 -24px;
      border-top-color: #00ff88;
      animation-duration: 1.5s;
      animation-direction: reverse;
    }
    
    &:nth-child(3) {
      width: 32px;
      height: 32px;
      margin: -16px 0 0 -16px;
      border-top-color: #ff6b6b;
      animation-duration: 2s;
    }
  }
}

.loading-text {
  color: #00d4ff;
  font-size: 16px;
  margin: 0;
  animation: glow 2s ease-in-out infinite alternate;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@keyframes glow {
  0% {
    text-shadow: 0 0 5px #00d4ff;
  }
  100% {
    text-shadow: 0 0 20px #00d4ff, 0 0 30px #00d4ff;
  }
}
</style>